#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>

typedef struct line
{
	int x;
	int y;
	int price;
}line;

int cmp(const void* a, const void* b)
{
	return ((line*)a)->price - ((line*)b)->price;
}

int find(int x, int* cloud)
{
	if (cloud[x] == 0)
		return x;
	else
		return find(cloud[x], cloud);
}

int union_cloud(line* a, int* cloud)
{
	int x = find(a->x, cloud);
	int y = find(a->y, cloud);
	if (x != y)
	{
		cloud[y] = x;
		return 1;
	}
	else
		return 0;
}

line price[1000];
int main()
{
	int n = 0, m = 0, k = 0;
	int ans = 0;
	int ph = 0;
	scanf("%d %d %d", &n, &m, &k);
	int* cloud = (int*)calloc(n + 1, sizeof(int));
	for (int i = 0; i < m; ++i)
	{
		scanf("%d %d %d", &(price[i].x), &(price[i].y), &(price[i].price));
	}
	qsort(price,m,sizeof(line),cmp);

	for (int i = 0; i < m; ++i)
	{
		if (union_cloud(&price[i], cloud))
		{
			++ans;
			ph += price[i].price;
		}
		if (ans == n - k)
		{
			printf("%d", ph);
			return 0;
		}
	}
	if (ans != n - k)
		printf("No Answer");
	return 0;
}